#include "fxcc/core/graph/opengl3/PickupEffect.h"

std::string fxcc::graph::opengl3::PickupEffect::FragCode()
{
    const std::string fragCode = R"(

out vec4 FragColor;

vec4 GetPickVec4FromObjId(int ObjectID)
{
    float r = (ObjectID & 0xFF) / 255.0;
    float g = ((ObjectID >> 8) & 0xFF) / 255.0;
    float b = ((ObjectID >> 16) & 0xFF) / 255.0;
    return vec4(r, g, b, 1.0);
}

void main()
{
int objId=objData.objId;
	FragColor=GetPickVec4FromObjId(objId);
	// FragColor=vec4(vec3(1.0f),1.0);
}
)";
    return fragCode;
}

fxcc::graph::opengl3::PickupEffect::PickupEffect()
    :fxcc::graph::opengl3::Effect3d(FragCode())
{
    m_PipeLineType.m_RasterizerType = fxcc::graph::common::RasterizerType::_NONE_;
    m_PipeLineType.m_DepthStencilType = fxcc::graph::common::DepthStencilType::_DEPTH_LESS_STENCIL_ALAWAYS_WRITE;
    m_PipeLineType.m_BlendType = fxcc::graph::common::BlendType::_NONE_;

}
void fxcc::graph::opengl3::PickupEffect::ClearBlackAlpha0() 
{
    glm::vec4 bgColor = glm::vec4(glm::vec3(0.0f), 1.0f);
    ClearBgColor(bgColor);
}

void fxcc::graph::opengl3::PickupEffect::Begin()
{
    fxcc::graph::opengl3::Effect3d::Begin();
}